package pt.ipleiria.estg.dei.ei.es2.bio;

import android.content.Context;
import android.preference.EditTextPreference;
import android.util.AttributeSet;

/**
 * Created by ASUS-PC on 12-03-2015.
 */
public class MyEditTextPreferences extends EditTextPreference {


    public MyEditTextPreferences(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onDialogClosed(boolean positiveResult) {
        super.onDialogClosed(positiveResult);

        if(positiveResult)
        {
            setSummary(getNewValue());
        }
    }

    private CharSequence getNewValue() {

        return getText().isEmpty()?super.getSummary(): getText();
    }
}
